package com.tuliyou.controller;

import com.tuliyou.common.util.Result;
import com.tuliyou.dto.MajorDTO;
import com.tuliyou.dto.PageInfo;
import com.tuliyou.service.MajorService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/majors")
public class MajorController {

    @Resource
    private MajorService majorService;

    @GetMapping
    public Result<PageInfo<MajorDTO>> getMajors(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer size,
            @RequestParam(required = false) String majorName, // 模糊查询
            @RequestParam(required = false) String parentCode, // 专业所属大类代码
            @RequestParam(required = false) String level, // 层级(1-学科门类,2-专业类,3-具体专业)
            @RequestParam(required = false) String degreeType, // 授予学位模糊查询
            @RequestParam(required = false) String years
    ) {
        return majorService.getMajors(page,size,majorName,parentCode,level,degreeType,years);
    }

    @GetMapping("/{majorCode}")
    public Result<MajorDTO> getMajorDetail(@PathVariable("majorCode") String majorCode){
        return majorService.getMajorDetail(majorCode);
    }


}
